package com.googlecode.grima.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.googlecode.grima.domain.Schedule;
import com.googlecode.grima.service.ScheduleService;

@Controller
public class ScheduleController extends PortalController {

	private static final long serialVersionUID = 1L;
	
	@Autowired
	private ScheduleService scheduleService;

	public ScheduleService getScheduleService() {
  	return scheduleService;
  }

	public void setScheduleService(ScheduleService scheduleService) {
  	this.scheduleService = scheduleService;
  }

	@RequestMapping(value = "/secure/schedule", method = RequestMethod.GET)
	public void schedule(ModelMap modelMap) {
		List<String> sections = new ArrayList<String>();
		for (int i = 1; i <= 10; i++) {
			sections.add("section"+i);
    }
		List<Schedule> schedules = new ArrayList<Schedule>();
		for (int i = 1; i <= 10; i++) {
			Schedule schedule = new Schedule();
			schedule.setDescription("task "+i);
			schedule.setStartDate(new Date());
			schedule.setEndDate(DateUtils.addDays(new Date(), 2));
			schedule.setStep("section"+i);
			schedules.add(schedule);
		}		
		
		modelMap.addAttribute("sections", sections);
		modelMap.addAttribute("schedules", schedules);

	}

}